package com.dxl.lanju.web.controller;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.dxl.common.annotation.RequirePermission;
import com.dxl.lanju.service.ReportService;
import com.dxl.web.common.controller.BaseController;

/**
 * 报表控制器
 * @author 邓小林
 */
@Controller
@RequestMapping("/report")
@RequirePermission(value={"REPORT-MODULE"}, name="报表模块", desc="包括各类报表展示")
public class ReportController extends BaseController {
	private static final Logger LOG = Logger.getLogger(ReportController.class);
	@Autowired
	private ReportService reportService;
	
	@RequestMapping("/shop")
	@RequirePermission(value={"REPORT-SHOP-VIEW"}, name="店铺报表查看", desc="店铺查看报表信息")
	public ModelAndView shop() {
		ModelAndView mv = new ModelAndView("report/shopStat");
		return mv;
	}
	
	@ResponseBody
	@RequestMapping("/shop/shopStat")
	@RequirePermission(value={"REPORT-SHOP-VIEW"}, name="店铺报表查看", desc="店铺报表查看")
	public Map<String, Object> shopStat(Integer page, Integer rows) {
		Map<String, Object> shopStat = reportService.shopStat();
		return shopStat;
	}
	
	@ResponseBody
	@RequestMapping("/shop/shopStatByShop")
	@RequirePermission(value={"REPORT-SHOP-VIEW"}, name="店铺报表查看", desc="店铺报表查看")
	public Map<String, Object> shopStat(String shopId, Integer page, Integer rows) {
		Map<String, Object> shopStat = reportService.shopStat(shopId);
		return shopStat;
	}
	
	@ResponseBody
	@RequestMapping("/shop/shopStatByShopDayDetail")
	@RequirePermission(value={"REPORT-SHOP-VIEW"}, name="店铺报表查看", desc="店铺报表查看")
	public Map<String, Object> shopStat(String shopId, String day, Integer page, Integer rows) {
		Map<String, Object> shopStat = reportService.shopStat(shopId, day);
		return shopStat;
	}
	
	@RequestMapping("/visit")
	@RequirePermission(value={"REPORT-SHOPVISIT-VIEW"}, name="店铺拜访报表查看", desc="店铺拜访查看报表信息")
	public ModelAndView shopVisit() {
		ModelAndView mv = new ModelAndView("report/shopVisit");
		return mv;
	}
	
	@ResponseBody
	@RequestMapping("/visit/visitDayList")
	@RequirePermission(value={"REPORT-SHOPVISIT-VIEW"}, name="店铺拜访报表查看", desc="店铺拜访报表查看")
	public List<Map<String, Object>> visitDayList(String areaId, Integer page, Integer rows) {
		List<Map<String, Object>> shopVisit = reportService.visitDayList(areaId);
		return shopVisit;
	}
	
	@ResponseBody
	@RequestMapping("/visit/shopVisitByAreaDay")
	@RequirePermission(value={"REPORT-SHOPVISIT-VIEW"}, name="店铺拜访报表查看", desc="店铺拜访报表查看")
	public Map<String, Object> shopVisitByAreaDay(String areaId, String day, Integer page, Integer rows) {
		Map<String, Object> shopVisit = reportService.shopVisit(areaId, day);
		return shopVisit;
	}
	
	@ResponseBody
	@RequestMapping("/visit/shopVisitByShopDay")
	@RequirePermission(value={"REPORT-SHOPVISIT-VIEW"}, name="店铺拜访报表查看", desc="店铺拜访报表查看")
	public Map<String, Object> shopVisitByShopDay(String areaId, String shopId, String day, Integer page, Integer rows) {
		Map<String, Object> shopVisit = reportService.shopVisit(areaId, shopId, day);
		return shopVisit;
	}
}
